package com.example;

import android.content.Context;
import android.content.res.Resources;
import ru.yandex.yandexmapkit.MapController;
import ru.yandex.yandexmapkit.MapView;
import ru.yandex.yandexmapkit.OverlayManager;
import ru.yandex.yandexmapkit.overlay.Overlay;
import ru.yandex.yandexmapkit.overlay.OverlayItem;
import ru.yandex.yandexmapkit.overlay.balloon.BalloonItem;
import ru.yandex.yandexmapkit.utils.GeoPoint;

/**
 * Created with IntelliJ IDEA.
 * User: Barsik
 * Date: 15.10.12
 * Time: 0:02
 * To change this template use File | Settings | File Templates.
 */
public class MapUtility {
    public static void showObject(MapView mapView){
        MapController mMapController;
        OverlayManager mOverlayManager;

        mMapController = mapView.getMapController();
        mOverlayManager = mMapController.getOverlayManager();
        // Disable determining the user's location
        mOverlayManager.getMyLocation().setEnabled(false);
        // Load required resources
        Context ctx = mapView.getContext();
        Resources res = ctx.getResources();

        // Create a layer of objects for the map
        Overlay overlay = new Overlay(mMapController);

        // Create an object for the layer
        final OverlayItem kremlin = new OverlayItem(new GeoPoint(55.752004 , 37.617017), res.getDrawable(R.drawable.shop));
        // Create a balloon model for the object
        BalloonItem balloonKremlin = new BalloonItem(ctx,kremlin.getGeoPoint());
        balloonKremlin.setText("point");
//        // Add the balloon model to the object
        kremlin.setBalloonItem(balloonKremlin);
        // Add the object to the layer
        overlay.addOverlayItem(kremlin);

        // Create an object for the layer
        final OverlayItem yandex = new OverlayItem(new GeoPoint(55.601404 , 37.274668), res.getDrawable(R.drawable.shop));
        // Create the balloon model for the object
        BalloonItem balloonYandex = new BalloonItem(ctx,yandex.getGeoPoint());
        balloonYandex.setText("point");
        // Add the balloon model to the object
        yandex.setBalloonItem(balloonYandex);
        // Add the object to the layer
        overlay.addOverlayItem(yandex);

        // Add the layer to the map
        mOverlayManager.addOverlay(overlay);

    }
}
